//
//  TDSearchCarListCell.m
//  TBRentClient
//
//  Created by tonbright on 2018/6/6.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TDSearchCarListCell.h"
#import "DWQRatingView.h"
#import "SDCycleScrollView.h"


@interface TDSearchCarListCell()<SDCycleScrollViewDelegate>
@property (nonatomic, strong) SDCycleScrollView *cycleScrollView;
@property (nonatomic,strong)DWQRatingView *starView;
@property (weak, nonatomic) IBOutlet UIView *view_container_star;//五星的容器视图---

@end
@implementation TDSearchCarListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, Width - 40, 220) delegate:self placeholderImage:[UIImage imageNamed:@"tdPlaceHold"]];
    cycleScrollView.autoScroll = NO;
    cycleScrollView.pageDotImage = [[UIImage imageNamed:@"矩形白色"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    cycleScrollView.currentPageDotImage = [UIImage imageNamed:@"矩形黑色"];
    cycleScrollView.pageControlDotSize = CGSizeMake(20, 5);
    self.cycleScrollView = cycleScrollView;
    cycleScrollView.layer.cornerRadius = 5;
    cycleScrollView.layer.masksToBounds = YES;
    [self.view_content addSubview:cycleScrollView];
    [self setupBottomView];
}


- (void)setCarListModel:(TDCarSourceListModel *)carListModel {
    _carListModel = carListModel;
    NSMutableArray *tmpImageArray = [NSMutableArray array];
    NSArray *tmpArray = carListModel.materiallist;
    for (TDCarSourceEnumCarModel *enumModel in tmpArray) {
        NSString *tmpImageUrl = [NSString stringWithFormat:@"http://121.40.92.131/deepdriving/%@",enumModel.linkurl];
        [tmpImageArray addObject:tmpImageUrl];
    }
    self.cycleScrollView.imageURLStringsGroup = tmpImageArray;
    
    _lbe_brandnm.text = [NSString stringWithFormat:@"%@ %@",carListModel.brandnm,carListModel.seriesnm];
    _lbe_typenm.text = carListModel.typenm;
    _lbe_price.text = [NSString stringWithFormat:@"¥ %@每天",carListModel.price];
    self.starView.scoreNum= @(carListModel.stars.doubleValue);
    self.lbe_storenm.text = [NSString stringWithFormat:@"%@ 距离%@KM",carListModel.storename,carListModel.distance];
    self.lbe_star.text = carListModel.stars;
    
}



#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    //    UINavigationController *nav = [BOAssistor getCurrentNav];
    //    BaseWebViewController *vc = [[BaseWebViewController alloc] initWithUrl:[NSURL URLWithString:@"http://www.baidu.com"]];
    //    [nav pushViewController:vc animated:YES];
    if (self.searchCarListCellBlock) {
        self.searchCarListCellBlock(_indexPath);
    }
}


- (void)setupBottomView {
    DWQRatingView *starView=[[DWQRatingView alloc] init];
    self.starView = starView;
    [self.view_container_star addSubview:starView];
    [starView makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.leading.trailing.top.offset(0);
    }];
    //    starView.needIntValue=NO;   //是否整数显示，默认整数显示
    starView.canTouch=NO;//是否可以点击，默认为NO
    //start2.scoreNum=@4;//星星显示个数
    self.starView.normalColorChain([UIColor lightGrayColor]);
    starView.highlightColorChian([UIColor redColor]);
    starView.scroreBlock=^(NSNumber *number){
        NSLog(@"返回的分数");
    };
}



@end
